package com.jokesoft.supermanager.rest;

import java.util.Iterator;
import java.util.List;

public class MandatoryParameterMissingException extends Exception {

    private final String errorMessage;

    public MandatoryParameterMissingException(List<String> parametersMissing) {
        StringBuilder errorMsgBuilder = new StringBuilder();
        errorMsgBuilder.append("Missing mandatory parameters [");
        for (Iterator<String> iter = parametersMissing.iterator(); iter.hasNext();) {
            errorMsgBuilder.append(iter.next());
            if (iter.hasNext()) {
                errorMsgBuilder.append(", ");
            }
        }
        errorMsgBuilder.append("] from request");
        this.errorMessage = errorMsgBuilder.toString();
    }

    private static final long serialVersionUID = 1L;

    public String getErrorMessage() {
        return this.errorMessage;
    }

}
